//
//  UIButton+Extension.swift
//  weibo
//
//  Created by Fly on 2017/12/28.
//  Copyright © 2017年 Fly. All rights reserved.
//

import Foundation
import UIKit

extension UIButton {
    
    // 扩展—便利构造函数
    convenience init(title: String, fontSize: CGFloat = 16.0, titleNormalColor: UIColor = UIColor.gray, titleHighlightedColor: UIColor = UIColor.black) {
        
        self.init()
        
        setTitle(title, for: .normal)
        
        titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
        
        setTitleColor(titleNormalColor, for: .normal)
        
        setTitleColor(titleHighlightedColor, for: .highlighted)
        
        sizeToFit()
        
    }

    // 扩展-新增方法
    open class func easyBtn(title: String, fontSize: CGFloat = 16.0, titleNormalColor: UIColor = UIColor.gray, titleHighlightedColor: UIColor = UIColor.black) -> UIButton {
        
        let btn = UIButton()
        
        btn.setTitle(title, for: .normal)
        
        btn.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
        
        btn.setTitleColor(titleNormalColor, for: .normal)
        
        btn.setTitleColor(titleHighlightedColor, for: .highlighted)
        
        btn.sizeToFit()
        
        return btn
    }


}
